package com.yujn.order.service;

import com.yujn.common.bean.Result;
import com.yujn.order.bean.User;
import com.yujn.order.feign.UserFeign;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Optional;

@Service
public class OrderServiceImpl implements OrderService {

    @Autowired
    private UserFeign userFeign;

    /**
     * 根据用户ID获取用户
     * @param id
     * @return
     */
    @Override
    public User getUserById(String id) {
        Result<User> result = userFeign.getUserById(id);
        return Optional.ofNullable(result)
                .map(p->p.getData())
                .orElse(null);
    }
}
